package robocup.component.infotypes;

/**
 * InitInfo.
 * 
 * Used to transmit player initialisation information at game start. Not REALLY
 * an aural info but fits best into this category.
 */
public class InitInfo
    extends AuralInfo {

  /**
   * The tricot number of the agent. This is assigned by the server in the order
   * of initialization (1..11).
   */
  private int     number   = -1;

  /**
   * A flag indicating, if the player is a goalie. This is set true, if the
   * player connected successfully as goalie.
   */
  private boolean isGoalie;

  /**
   * The teamname, with which the agent connected to the server.
   */
  private String  teamName = "NO TEAMNAME IN INIT";

  /**
   * Constructs an init-info object which is received after connecting to the
   * server.
   * 
   * @param iCycle -
   *          the cycle, when it was received
   * @param iNumber -
   *          the given number <unum> from the server.
   * @param iIsGoalie -
   *          if we are goalie or not
   */
  public InitInfo(
      final int iCycle,
      final int iNumber,
      final boolean iIsGoalie) {

    super(iCycle);
    this.number = iNumber;
    this.isGoalie = iIsGoalie;
    this.infoType = Info.TYPE_INIT;
  }

  /**
   * Constructs an init-info object which is received after connecting to the
   * server.
   * 
   * @param iCycle -
   *          the cycle, when it was received
   * @param iNumber -
   *          the given number <unum> from the server.
   * @param iIsGoalie -
   *          if we are goalie or not
   * @param iTeamName -
   *          the team-name
   */
  public InitInfo(
      final int iCycle,
      final int iNumber,
      final boolean iIsGoalie,
      final String iTeamName) {

    super(iCycle);
    this.number = iNumber;
    this.isGoalie = iIsGoalie;
    this.teamName = iTeamName;
    this.infoType = Info.TYPE_INIT;
  }

  /**
   * Setter for the tricot number
   * 
   * @param number
   */
  public void setNumber(final int number) {

    this.number = number;
  }

  /**
   * @return player number transmitted through the info message
   */
  public final int number() {

    return this.number;
  }

  /**
   * @return true if player is goalie
   */
  public final boolean isGoalie() {

    return this.isGoalie;
  }

  /**
   * @return Returns the teamName.
   */
  public final String getTeamName() {

    return this.teamName;
  }

  /**
   * @return A debug string for this info.
   */
  @Override
  public String toString() {

    return ("PlayerInfo: Number: " + this.number + ", isGoalie: " + (this.isGoalie ? "yes" : "no") + ", TeamName: " + this.teamName);
  }
}
